<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //猜数字小游戏
      var x = prompt("x=?");
      if (x > 10) {
        console.log("猜大了");
      } else if (x < 0) {
        console.log("猜小了");
      } else if (x >= 0 && x <= 10) {
        if (x == 5) {
          console.log("猜对了");
        } else {
          console.log("猜错了，再试试吧");
        }
      } else {
        console.log("输入不合法");
      }
    </script>
  </body>
</html>
